import { Nodes } from '@knno/dom';
import { PulldownEventMap, Pulldown as UIPulldown } from '../components/pulldown/pulldown';
import { JSXProps } from '@knno/dom/jsx';
import { AttrCheck, On, isBool, isFunc, jsxBuild } from './utils';

export { UIPulldown };

interface PulldownProps extends JSXProps<UIPulldown>, On<PulldownEventMap, UIPulldown> {
	onRefresh: (this: UIPulldown) => Promise<void>;
	mouseScroll?: boolean;
}

const ATTRS: AttrCheck = {
	onRefresh: isFunc,
	mouseScroll: isBool,
};

export function Pulldown(props: PulldownProps, children: Nodes[]): UIPulldown {
	return jsxBuild(new UIPulldown(), props, children, ATTRS);
}
